define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
	
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/comment/index',
                    del_url: 'user/comment/del',
                    table: 'notice',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), sortable: true},
                        {field: 'nick', title: __('Nick'), operate: 'LIKE'},
                        {field: 'email', title: __('Email'), operate: 'LIKE'},
                        {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
                        {field: 'content', title: __('Content'), formatter: function(value){
                        	return (value.length > 30)?value.substring(0, 30) + '...' : value;
                        }},
                        {field: 'addtime', title: __('AddTime'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: 
                        	function(value, row, index) {
                        		this.buttons = 
                        		[
                        			{
                        				name: 'bill',
                        				title: __('Bill'),
                        				classname: 'btn btn-xs btn-warning',
                        				icon: 'fa fa-commenting',
                        				url: 'user/comment/view',
                        			}
                    			];
                        		return Table.api.formatter.operate.call(this, value, row, index);
                        	}
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});